<canvas id="canvas" width="300" height="300"></canvas>
<a href="https://vd2.bdstatic.com/mda-mh19x922jgu5h6mj/720p_frame30/h264_cae_acd/1673882522278667085/mda-mh19x922jgu5h6mj.mp4?v_from_s=bdapp-unicomment-hnb">点击
    
</a>

<script>
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');

// 在canvas上绘制二维码
// ...

var startY = 50; // 线的起始位置
var endY = 250; // 线的终止位置
var color = 'red'; // 线的颜色
var lineWidth = 2; // 线的宽度

setInterval(function() {
  // 清空canvas
  ctx.clearRect(0, 0, canvas.width, canvas.height);

  // 在canvas上绘制二维码
  // ...

  // 绘制线
  ctx.beginPath();
  ctx.moveTo(0, startY);
  ctx.lineTo(canvas.width, endY);
  ctx.strokeStyle = color;
  ctx.lineWidth = lineWidth;
  ctx.stroke();

  // 更新线的位置
  startY += 5;
  endY += 5;

  // 边界检测
  if (startY > canvas.height) {
    startY = -lineWidth;
    endY = canvas.height + lineWidth;
  }
}, 50); // 每50毫秒重绘一次canvas
</script>
